﻿<!--*************************************************************************************

   Toolkit for WPF

   Copyright (C) 2007-2016 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   For more features, controls, and fast professional support,
   pick up the Plus Edition at https://xceed.com/xceed-toolkit-plus-for-wpf/

   Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids

  ***********************************************************************************-->

<local:DemoView x:Class="Xceed.Wpf.Toolkit.LiveExplorer.Samples.Magnifier.Views.MagnifierView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:local="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer"
                 xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                 xmlns:sys="clr-namespace:System;assembly=mscorlib"
                 xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.LiveExplorer.Samples.Magnifier.Converters"
                 Title="Magnifier">
   <local:DemoView.Description>
      <Paragraph FontSize="14" FontFamily="Segoe">
         The Magnifier control allows the user to magnify parts of an application.
      </Paragraph>
   </local:DemoView.Description>

   <local:DemoView.Resources>
      <xctk:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter" />
      <conv:VisibilityConverter x:Key="visibilityConverter" />
      <xctk:RtfFormatter x:Key="rtfFormatter" />
      <xctk:BorderThicknessToStrokeThicknessConverter x:Key="BorderThicknessToStrokeThicknessConverter"/>

      <ObjectDataProvider x:Key="enumData" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
         <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="xctk:FrameType"/>
         </ObjectDataProvider.MethodParameters>
      </ObjectDataProvider>
   </local:DemoView.Resources>

   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>

      <GroupBox Header="Features" Grid.Row="0" Margin="5">
         <Grid Margin="5" HorizontalAlignment="Left">
            <Grid.RowDefinitions>
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="Auto" />
               <ColumnDefinition Width="100" />
               <ColumnDefinition Width="Auto" />
               <ColumnDefinition Width="100" />
               <ColumnDefinition Width="Auto" />
               <ColumnDefinition Width="100" />
            </Grid.ColumnDefinitions>
            <!-- First Column-->
            <TextBlock Text="Zoom Factor:" VerticalAlignment="Center" Margin="5" />
            <xctk:DoubleUpDown x:Name="_zoomFactor" Grid.Column="1" Value="{Binding ZoomFactor, ElementName=_magnifier}" Minimum="0" Increment="0.1" Maximum="3" FormatString="N1" Margin="5" />
            <TextBlock Text="IsUsingZoomOnMouseWheel:" Grid.Row="1" VerticalAlignment="Center" Margin="5" />
            <CheckBox x:Name="_isUsingZoomOnMouseWheel" Grid.Row="1" Grid.Column="1" IsChecked="{Binding IsUsingZoomOnMouseWheel, ElementName=_magnifier}" Margin="5" />
            <TextBlock Text="ZoomFactorOnMouseWheel:" Grid.Row="2" VerticalAlignment="Center" Margin="5" />
            <xctk:DoubleUpDown x:Name="_zoomFactorOnMouseWheel" Grid.Row="2" Grid.Column="1" Value="{Binding ZoomFactorOnMouseWheel, ElementName=_magnifier}" Minimum="0" Increment="0.05" Maximum="1" FormatString="N2" Margin="5" />
            <!-- Second Column-->
            <TextBlock Grid.Column="2" Text="Frame Type:" VerticalAlignment="Center" Margin="10,0,0,0"/>
            <ComboBox x:Name="_frameType" SelectedItem="{Binding FrameType, ElementName=_magnifier}" ItemsSource="{Binding Source={StaticResource enumData}}" Grid.Column="3" Margin="5" />
            <TextBlock Text="Radius:" Grid.Row="1" Grid.Column="2" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=0}" VerticalAlignment="Center" Margin="10,0,0,0"/>
            <xctk:DoubleUpDown x:Name="_radius" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=0}" Grid.Row="1" Grid.Column="3" Value="{Binding Radius, ElementName=_magnifier}"  Minimum="0" Maximum="150" Margin="5"  />
            <TextBlock Text="RectangleWidth:" Grid.Row="1" Grid.Column="2" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=1}" VerticalAlignment="Center" Margin="10,0,0,0"/>
            <xctk:DoubleUpDown x:Name="_width" Grid.Row="1" Grid.Column="3" Value="{Binding Width, ElementName=_magnifier}"  Minimum="0" Maximum="300" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=1}" Margin="5"  />
            <TextBlock Text="RectangleHeight:" Grid.Row="2" Grid.Column="2" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=1}" VerticalAlignment="Center" Margin="10,0,0,0"/>
            <xctk:DoubleUpDown  x:Name="_height" Grid.Row="2" Grid.Column="3" Value="{Binding Height, ElementName=_magnifier}" Minimum="0" Maximum="300" Visibility="{Binding ElementName=_frameType, Path=SelectedItem, Converter={StaticResource visibilityConverter}, ConverterParameter=1}" Margin="5"  />
            <!-- Third Column -->
            <TextBlock Text="Border Thickness:" Grid.Column="4" VerticalAlignment="Center" Margin="5" />
            <xctk:IntegerUpDown x:Name="_borderThickness" Grid.Column="5" Value="{Binding BorderThickness, ElementName=_magnifier, Converter={StaticResource BorderThicknessToStrokeThicknessConverter}}" Minimum="0" Maximum="20" Margin="5" />
            <TextBlock Text="Border Brush:" Grid.Row="1" Grid.Column="4" VerticalAlignment="Center" Margin="5"/>
            <xctk:ColorPicker x:Name="_colorPicker" Grid.Row="1" Grid.Column="5" Margin="5" SelectedColor="{Binding BorderBrush, ElementName=_magnifier, Converter={StaticResource SolidColorBrushToColorConverter}}"/>
         </Grid>
      </GroupBox>

      <StackPanel Grid.Row="1" Margin="10" HorizontalAlignment="Left" >
         <TextBlock Text="Usage:" Style="{StaticResource Header}"/>
         <xctk:RichTextBox x:Name="_txtContent"
                              IsReadOnly="True" 
                              TextFormatter="{StaticResource rtfFormatter}" 
                              FontSize="10" >
            <xctk:MagnifierManager.Magnifier>
               <xctk:Magnifier x:Name="_magnifier"
                               Background="White"
                               Radius="80"
                               ZoomFactor="0.4"
                               FrameType="Circle"
                               BorderBrush="#FFC72035"
                               BorderThickness="2"
                               Width="160"
                               Height="160"
                               IsUsingZoomOnMouseWheel="True"
                               ZoomFactorOnMouseWheel="0.1"/>
            </xctk:MagnifierManager.Magnifier>
         </xctk:RichTextBox>
      </StackPanel>
   </Grid>
</local:DemoView>
